package com.bwda.dsrs.filecenter.controller;

import com.bwda.dsrs.base.centerbase.response.ResponseEntity;
import com.bwda.dsrs.filecenter.aspect.LogTypeEnum;
import com.bwda.dsrs.filecenter.aspect.Loggable;
import com.bwda.dsrs.filecenter.domain.exception.BusinessServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 通用请求处理
 * 经确认，已经没有地方用到这个请求了，先删除配置文件upload_path，download_path试试，没问题再删除代码
 *
 * @author youzhen
 */
@ApiIgnore
@Controller
@RequestMapping("/b/common")
public class FileCommonController extends BaseController {

    private static final Logger log = LoggerFactory.getLogger(FileCommonController.class);


    /**
     * 通用下载请求
     *
     * @param fileName 文件名称
     * @param delete   是否删除
     */
    @Loggable(descp = " 通用请求处理下载", type = LogTypeEnum.DOWNLOAD, include = "")
    @RequestMapping(value = "/download", method = {RequestMethod.GET, RequestMethod.POST})
    public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {

    }

    /**
     * 通用上传请求
     */
    @Loggable(descp = " 通用请求处理上传", type = LogTypeEnum.UPLOAD, include = "")
    @RequestMapping(value = "/upload", method = {RequestMethod.POST})
    @ResponseBody
    public ResponseEntity<String> uploadFile(MultipartFile file) throws BusinessServiceException, IOException {

        return getSuccessResult("此方法已废弃");
    }


}
